package com.nnnu.wsnackshop.controller;

import com.nnnu.wsnackshop.controller.base.BaseController;
import com.nnnu.wsnackshop.result.Result;
import com.nnnu.wsnackshop.service.IOrdersService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author zk
 * @since 2025-05-14
 */
@RestController
@RequestMapping("/orders")
@Slf4j
@RequiredArgsConstructor
public class OrdersController extends BaseController {

    private final IOrdersService ordersService;

    /**
     * 获取骑手位置信息
     */
    @GetMapping("/{id}/rider-location")
    public Result<Map<String, Object>> getRiderLocation(@PathVariable Long id) {
        log.info("获取骑手位置信息: orderId={}", id);
        // 获取订单的配送信息和骑手位置
        Map<String, Object> locationInfo = ordersService.getRiderLocationByOrderId(id);
        return Result.success(locationInfo);
    }

    /**
     * 获取订单配送信息
     */
    @GetMapping("/{id}/delivery-info")
    public Result<Map<String, Object>> getDeliveryInfo(@PathVariable Long id) {
        log.info("获取订单配送信息: orderId={}", id);
        // 获取订单的配送详情
        Map<String, Object> deliveryInfo = ordersService.getDeliveryInfoByOrderId(id);
        return Result.success(deliveryInfo);
    }
}
